using Assets.Scripts.GDK;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

namespace Brick
{
	public class LogoScene : gdk_base_scene
	{
		public Scrollbar scrollbar;

		public override void OnStart()
		{
			//测试,清除数据 --shicy
			//PlayerPrefs.DeleteAll();

			//广告管理类挂载对象 --shicy
			/* if(GameObject.Find("AdsManager") == null)
			 {
				 GameObject go = new GameObject("AdsManager");
				 go.AddComponent<AdsManager>();
			 }*/

			Input.multiTouchEnabled = false;
			scrollbar.size = 0f;
			DOTween.To(() => 1, delegate (int x)
			{
				scrollbar.size = (float)x / 100f;
			}, 99, 1f).OnComplete(delegate
			{
				PoolPlayer.Instance.OnStart();
				UnityEngine.Debug.Log("完成!");
				loadAPPJson();
				//SDKManager.Init(delegate
				//{
				//	UnityEngine.Debug.Log("初始化完成,获取到配置");
				//});
				//loadGameConfigJson();
				//loadDaysJson();
				loadPiFuJson();
				//loadGameShopJson();
				UnityEngine.Debug.Log("完成! 2");
				//loadprefabs();
				UnityEngine.SceneManagement.SceneManager.LoadScene(SceneID.START);
				//gdk_game_manager.loadScene(SceneID.START);
			});
		}

		private void loadprefabs()
		{
			loadPreRes(20, "sanjiao_suikuai01", "Prefabs/effect/sanjiao_suikuai01");
			loadPreRes(20, "sanjiao_suikuai01", "Prefabs/effect/sanjiao_suikuai02");
			loadPreRes(20, "sanjiao_suikuai01", "Prefabs/effect/sanjiao_suikuai03");
			loadPreRes(20, "sanjiao_suikuai01", "Prefabs/effect/sanjiao_suikuai04");
			loadPreRes(20, "sanjiao_suikuai01", "Prefabs/effect/zhadanbaozha");
			loadPreRes(100, "sanjiao_suikuai01", "Prefabs/effect/fangkuai");
			loadPreRes(150, "Prefabs/Type1/type_1_0", "Prefabs/Type1/type_1_0");
			loadPreRes(20, "Prefabs/Type1/type_1_1", "Prefabs/Type1/type_1_1");
			loadPreRes(20, "Prefabs/Type1/type_1_2", "Prefabs/Type1/type_1_2");
			loadPreRes(20, "Prefabs/Type1/type_1_3", "Prefabs/Type1/type_1_3");
			loadPreRes(20, "Prefabs/Type1/type_1_4", "Prefabs/Type1/type_1_4");
			loadPreRes(20, "Prefabs/Type1/type_1_4", "Prefabs/Type1/type_1_4");
			loadPreRes(20, "Prefabs/Type1/type_1_4", "Prefabs/Type1/type_1_4");
			loadPreRes(15, "Prefabs/Type2/type_2_0", "Prefabs/Type2/type_2_0");
		}

		private void loadPreRes(int num, string filename, string pathName)
		{
			EnemyPool.GetInstance().CreateObj(num, filename, pathName, PoolPlayer.Instance.GetObj());
		}

		private void loadAPPJson()
		{

		}

		private void loadDaysJson()
		{
			DaysListModel daysListModel = GDK.ModuleManger.Module<LogoSceneModule>().loadDaysJson();
			GameManager.setDaysModelArray(daysListModel.list, daysListModel.list2);
		}

		private void loadPiFuJson()
		{
			PiFuListModel piFuListModel = GDK.ModuleManger.Module<LogoSceneModule>().loadPiFuJson();
			GameManager.setPifuModelArray(piFuListModel.ballArray);
		}

		private void loadGameShopJson()
		{
			GameShopListModel gameShopListModel = GDK.ModuleManger.Module<LogoSceneModule>().loadGameShopJson();
			GameManager.setGameShopModelArray(gameShopListModel.list);
			GameManager.setGameGiftModelArray(gameShopListModel.giftList);
		}

		private void loadGameConfigJson()
		{
			GameConfigModel gameConfig = GDK.ModuleManger.Module<LogoSceneModule>().loadGameConfigJson();
			Debug.Log("gameConfig_________" + gameConfig);
			GameManager.setGameConfig(gameConfig);
		}
	}
}

